<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="layout: posttitle: “Ardb简介”description: “”category: Ardb
tags: [Ardb, Redis]           简介Ardb是一个C/C++开发的完全兼容Redis协议的NoSQL存储服务，支持绝大部分Redis命令以及数据结构如list/hash/set/sorted set，你可以很容易将依赖redis的业务在Redis和Ardb">
<meta property="og:type" content="article">
<meta property="og:title" content="隐去其闻">
<meta property="og:url" content="http://yinqiwen.github.io/uncategorized/2014/08/23/ardbintroduction.html">
<meta property="og:site_name" content="隐去其闻">
<meta property="og:description" content="layout: posttitle: “Ardb简介”description: “”category: Ardb
tags: [Ardb, Redis]           简介Ardb是一个C/C++开发的完全兼容Redis协议的NoSQL存储服务，支持绝大部分Redis命令以及数据结构如list/hash/set/sorted set，你可以很容易将依赖redis的业务在Redis和Ardb">
<meta property="og:updated_time" content="2016-06-30T13:54:20.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="隐去其闻">
<meta name="twitter:description" content="layout: posttitle: “Ardb简介”description: “”category: Ardb
tags: [Ardb, Redis]           简介Ardb是一个C/C++开发的完全兼容Redis协议的NoSQL存储服务，支持绝大部分Redis命令以及数据结构如list/hash/set/sorted set，你可以很容易将依赖redis的业务在Redis和Ardb">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://yinqiwen.github.io/uncategorized/2014/08/23/ardbintroduction.html"/>

  <title>  | 隐去其闻 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">隐去其闻</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2014-08-23T12:00:00+08:00" content="2014-08-23">
              2014-08-23
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/uncategorized/2014/08/23/ardbintroduction.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="uncategorized/2014/08/23/ardbintroduction.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <hr>
<p>layout: post<br>title: “Ardb简介”<br>description: “”<br>category: Ardb</p>
<h2 id="tags-Ardb-Redis"><a href="#tags-Ardb-Redis" class="headerlink" title="tags: [Ardb, Redis]           "></a>tags: [Ardb, Redis]           </h2><h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>Ardb是一个C/C++开发的完全兼容Redis协议的NoSQL存储服务，支持绝大部分Redis命令以及数据结构如list/hash/set/sorted set，你可以很容易将依赖redis的业务在Redis和Ardb之间来回迁移。 </p>
<p>Ardb的存储基于现有成熟的KV存储引擎实现，理论上任何类似B-Tree/LSM Tree实现的KV存储实现均可作为Ardb的底层存储实现，目前Ardb支持LevelDB/RocksDB/LMDB.  </p>
<p>Ardb项目的目的不是为了替换Redis（这点很重要）， 而是作为Redis的补充存在。Ardb重点解决的是在性能可接受的情况下单机支持远超过内存限制的数据量， 以及与Redis之间的互通的问题。</p>
<h2 id="特性"><a href="#特性" class="headerlink" title="特性"></a>特性</h2><p>最新的Ardb版本支持如下特性：   </p>
<ul>
<li>完全支持Redis协议， 包括早期的协议（可用telnet连接Ardb实例）</li>
<li>支持绝大部分redis命令，所有数据结构Set/Hash/List/Sorted Set， Lua脚本支持， PubSub，Transaction等等</li>
<li>支持所有数据结构的Key的Expire过期自动删除机制</li>
<li>兼容Redis主从复制机制。你可以把Ardb作为Redis实例的Slave或者将Redis作为Ardb的Slave，支持Redis2.6以及2.8+。</li>
<li>兼容Redis Sentinel的主从切换机制，你可以用Redis Sentinel监控主从节点并在节点异常情况下切换。</li>
<li>支持Redis的dump备份数据文件通过import命令在线导入；Save/BGSave命令将Ardb数据用Redis Dump格式导出</li>
<li>支持类似Redis的分库机制， 库ID范围为0到0xFFFFFF,无需预先指定</li>
<li><strong>内置二维空间索引实现，基于扩展的GeoAdd/GeoSearch命令实现二维空间查找特性。</strong></li>
<li>支持LevelDB/RocksDB/LMDB作为底层的存储引擎</li>
<li>兼容所有的Redis的Client实现，你可以用任意Redis的client实现连接Ardb实例</li>
<li><strong>多端口服务支持，读写端口分离， QPS限制， IP白名单等高级特性</strong></li>
<li>支持作为一个库内置到其他服务中</li>
</ul>
<a id="more"></a>
<h2 id="Ardb支持的Redis命令情况"><a href="#Ardb支持的Redis命令情况" class="headerlink" title="Ardb支持的Redis命令情况"></a>Ardb支持的Redis命令情况</h2><p>以Redis2.8.9为比较标准，未列出的均是已经支持且与Redis语义相同的命令： </p>
<h3 id="不支持"><a href="#不支持" class="headerlink" title="不支持"></a>不支持</h3><ul>
<li>OBJECT</li>
<li>DEBUG</li>
</ul>
<h3 id="支持，但语义有不同之处"><a href="#支持，但语义有不同之处" class="headerlink" title="支持，但语义有不同之处"></a>支持，但语义有不同之处</h3><ul>
<li>dbsize， 返回磁盘占用空间（字节数）</li>
<li>setbit/getbit/bitcount/bitop, Ardb中用bitset结构保存而非string，可以支持非常大的offset</li>
<li>info， 和redis的输出大有不同</li>
</ul>
<h3 id="新增"><a href="#新增" class="headerlink" title="新增"></a>新增</h3><ul>
<li>GeoAdd/GeoSearch， 空间索引</li>
<li>Cache， High Level的cache</li>
<li>Import， 在线导入备份数据，支持Redis Dump以及Ardb Dump</li>
<li>Compact/CompactAll， 后台comapct数据， 对LevelDB/RocksDB有效</li>
</ul>
<h2 id="Ardb-VS-Redis"><a href="#Ardb-VS-Redis" class="headerlink" title="Ardb VS Redis"></a>Ardb VS Redis</h2><h3 id="劣势"><a href="#劣势" class="headerlink" title="劣势"></a>劣势</h3><ul>
<li>性能，Redis大部分读写操作是O(1),且完全在内存上执行；KV存储引擎均是类似Tree结构（B-Tree， LSM-Tree等），读一般是Log（n），写性能LSM-Tree可能视作O(1)。</li>
<li>集群，Redis3.0已经支持集群，Ardb目前不支持</li>
<li>原子性（Atomic）， 由于Redis是单线程的服务，天生所有操作均具有原子性</li>
<li>稳定性</li>
<li>功能</li>
</ul>
<h3 id="优势"><a href="#优势" class="headerlink" title="优势"></a>优势</h3><ul>
<li>单机存储数据量以及同等数据量下的存储成本</li>
<li>读写多线程，可以充分利用多核机器的CPU</li>
<li>支持二维空间索引</li>
<li>读写端口分离， QPS限制， IP白名单等高级特性</li>
</ul>
<h3 id="复杂度"><a href="#复杂度" class="headerlink" title="复杂度"></a>复杂度</h3><p>Resis的存储结构基本是hash， 所以大部分读写是O(1); Ardb底层的存储引擎都是某种Tree的实现，若数据未在缓存中，则读复杂度基本和Tree的查询复杂度是一个数量级；写操作在LSM-Tree可能视作O(1)。另外需要差别较大需要注意的是， sorted set的类似rank操作在Ardb中都是类似O（n）的复杂度。</p>
<h2 id="Benchmark"><a href="#Benchmark" class="headerlink" title="Benchmark"></a>Benchmark</h2><ul>
<li>可以用Redis自带的benchmark测试Ardb服务.</li>
<li>现有的一些测试数据可以在github项目首页找到. <a href="https://github.com/yinqiwen/ardb" target="_blank" rel="external">Ardb</a></li>
</ul>
<h2 id="编译部署"><a href="#编译部署" class="headerlink" title="编译部署"></a>编译部署</h2><p>执行如下命令下载编译最新源码   </p>
<pre><code>git clone --depth=1 https://github.com/yinqiwen/ardb.git
cd ardb
make
</code></pre><p>若选择其他存储引擎实现， 如rocksdb，则需要在make前制定环境变量storage_engine， 如：</p>
<pre><code>storage_engine=rocksdb make
</code></pre><p>编译完成后，在src目录下生成ardb-server, ardb-test两个可执行文件，前者为服务， 后者为单元测试程序。配置文件模板为ardb.conf, 在ardb根目录下。按如下方式启动：</p>
<pre><code>cd src
./ardb-server ../ardb.conf
</code></pre>
      
    </div>

    <div>
      
        
      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/技术/2014/08/24/geohash.html" rel="prev" title="GeoHash介绍与改进的GeoHash-Int">
                GeoHash介绍与改进的GeoHash-Int <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="uncategorized/2014/08/23/ardbintroduction.html"
           data-title="" data-url="http://yinqiwen.github.io/uncategorized/2014/08/23/ardbintroduction.html">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="yinqiwen" />
          <p class="site-author-name" itemprop="name">yinqiwen</p>
          <p class="site-description motion-element" itemprop="description">Tech & Think</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">17</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">11</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#tags-Ardb-Redis"><span class="nav-number">1.</span> <span class="nav-text">tags: [Ardb, Redis]           </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#简介"><span class="nav-number">2.</span> <span class="nav-text">简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#特性"><span class="nav-number">3.</span> <span class="nav-text">特性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Ardb支持的Redis命令情况"><span class="nav-number">4.</span> <span class="nav-text">Ardb支持的Redis命令情况</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#不支持"><span class="nav-number">4.1.</span> <span class="nav-text">不支持</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#支持，但语义有不同之处"><span class="nav-number">4.2.</span> <span class="nav-text">支持，但语义有不同之处</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#新增"><span class="nav-number">4.3.</span> <span class="nav-text">新增</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Ardb-VS-Redis"><span class="nav-number">5.</span> <span class="nav-text">Ardb VS Redis</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#劣势"><span class="nav-number">5.1.</span> <span class="nav-text">劣势</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#优势"><span class="nav-number">5.2.</span> <span class="nav-text">优势</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#复杂度"><span class="nav-number">5.3.</span> <span class="nav-text">复杂度</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Benchmark"><span class="nav-number">6.</span> <span class="nav-text">Benchmark</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#编译部署"><span class="nav-number">7.</span> <span class="nav-text">编译部署</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2013 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yinqiwen</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"yinqiwen"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
  






  
  
  

  

  

</body>
</html>
